package com.answer.petsale.mapper;

import com.answer.petsale.model.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDateTime;

public interface OrderMapper extends BaseMapper<Order> {

    /**
     * 新增：计算指定时间范围内的销售总额
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return 销售总额
     */
    @Select("SELECT SUM(finalPrice) FROM orders WHERE status = 1 AND payTime >= #{startTime} AND payTime < #{endTime}")
    BigDecimal sumSalesBetweenDates(@Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);

}
